/*
 * Start.java
 *
 * Created on 21 luglio 2008, 21.46
 */
package monopoli.gui;

import javax.swing.JFrame;
import monopoli.MonopoliView;
import org.jdesktop.application.Action;
import monopoli.Monopoli;

/**
 *
 * @author  Claudio
 */
public class Start extends javax.swing.JPanel {

    private MonopoliView monopoliView;
    private JFrame main;

    /** Creates new form Start */
    public Start(JFrame m, MonopoliView mv) {


        initComponents();

        monopoliView = mv;
        main = m;
        //nascondo i controlli che all'inizio non devono essere visibili

        cmdPartecipa.setVisible(false);
        lblNomeGiocatore.setVisible(false);
        txtNomeGiocatore.setVisible(false);
        cmdAvvia.setVisible(true);
        jLabel1.setVisible(true);
        jLabel2.setVisible(true);
        this.repaint();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        cmdAvvia = new javax.swing.JButton();
        txtNomeGiocatore = new javax.swing.JTextField();
        cmdPartecipa = new javax.swing.JButton();
        lblNomeGiocatore = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(monopoli.MonopoliApp.class).getContext().getResourceMap(Start.class);
        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        cmdAvvia.setFont(resourceMap.getFont("cmdAvvia.font")); // NOI18N
        cmdAvvia.setText(resourceMap.getString("cmdAvvia.text")); // NOI18N
        cmdAvvia.setToolTipText(resourceMap.getString("cmdAvvia.toolTipText")); // NOI18N
        cmdAvvia.setName("cmdAvvia"); // NOI18N
        cmdAvvia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAvviaActionPerformed(evt);
            }
        });

        txtNomeGiocatore.setText(resourceMap.getString("txtNomeGiocatore.text")); // NOI18N
        txtNomeGiocatore.setToolTipText(resourceMap.getString("txtNomeGiocatore.toolTipText")); // NOI18N
        txtNomeGiocatore.setName("txtNomeGiocatore"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(monopoli.MonopoliApp.class).getContext().getActionMap(Start.class, this);
        cmdPartecipa.setAction(actionMap.get("Partecipa")); // NOI18N
        cmdPartecipa.setFont(new java.awt.Font("Segoe Print", 0, 14));
        cmdPartecipa.setText(resourceMap.getString("cmdPartecipa.text")); // NOI18N
        cmdPartecipa.setName("cmdPartecipa"); // NOI18N

        lblNomeGiocatore.setFont(resourceMap.getFont("lblNomeGiocatore.font")); // NOI18N
        lblNomeGiocatore.setText(resourceMap.getString("lblNomeGiocatore.text")); // NOI18N
        lblNomeGiocatore.setName("lblNomeGiocatore"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(86, 86, 86)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNomeGiocatore)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(cmdPartecipa, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmdAvvia, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel1)
                                .addComponent(txtNomeGiocatore, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(171, 171, 171)
                        .addComponent(jLabel2)))
                .addContainerGap(85, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblNomeGiocatore)
                .addGap(15, 15, 15)
                .addComponent(txtNomeGiocatore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmdPartecipa)
                    .addComponent(cmdAvvia, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(71, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

private void cmdAvviaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAvviaActionPerformed

    cmdAvvia.setVisible(false);
    cmdPartecipa.setVisible(true);
    lblNomeGiocatore.setVisible(true);
    txtNomeGiocatore.setVisible(true);

}//GEN-LAST:event_cmdAvviaActionPerformed

    @Action
    public void Partecipa() {


        String s = txtNomeGiocatore.getText();
        Monopoli.getMonopoliGUI().debugMessage("[DBG_gui] Partecipa alla partita il giocatore " + s);
        monopoli.Monopoli.getMonopoliPartita().getGameToGUI().avvioGioco(s);
        this.setVisible(false);
        main.remove(this);
        monopoliView.showSelectIcon();

    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cmdAvvia;
    private javax.swing.JButton cmdPartecipa;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel lblNomeGiocatore;
    private javax.swing.JTextField txtNomeGiocatore;
    // End of variables declaration//GEN-END:variables
}
